package org.zs.miracle.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zs.miracle.common.base.dto.BaseLongIdDTO;
import org.zs.miracle.common.base.dto.BaseManyLongIdDTO;
import org.zs.miracle.service.route.IRouteService;
import org.zs.miracle.service.route.model.dto.AddRouteDTO;
import org.zs.miracle.service.route.model.dto.EditRouteDTO;
import org.zs.miracle.service.route.model.dto.RouteQueryPageDTO;
import org.zs.miracle.service.route.model.vo.RouteVO;

/**
 * 骑行路线表Controller层,接受处理请求
 */
@Tag(name = "骑行路线接口")
@RestController
@RequestMapping("/route")
@AllArgsConstructor
public class RouteController {
  
  @Resource
  IRouteService routeService;
  
  @Operation(summary = "分页查询", description = "分页查询骑行路线接口}")
  @GetMapping(value = "/pageQueryList", produces = MediaType.APPLICATION_JSON_VALUE)
  @ApiResponse(responseCode = "200", description = "OK")
  public Page<RouteVO> pageQueryList(RouteQueryPageDTO inputDTO) {
    return routeService.pageQueryList(inputDTO);
  }
  
  @Operation(summary = "ID查询", description = "ID查询骑行路线接口}")
  @GetMapping(value = "/getRoute", produces = MediaType.APPLICATION_JSON_VALUE)
  @ApiResponse(responseCode = "200", description = "OK")
  public RouteVO getOne(@Validated BaseLongIdDTO inputDTO) {
    return routeService.getOne(inputDTO);
  }
  
  @Operation(summary = "添加骑行路线", description = "添加骑行路线接口")
  @ApiResponse(responseCode = "200", description = "OK")
  @PostMapping(value = "/addRoute", produces = MediaType.APPLICATION_JSON_VALUE)
  public Boolean addRoute(@RequestBody @Validated AddRouteDTO inputDTO) {
    return routeService.addRoute(inputDTO);
  }
  
  @Operation(summary = "删除骑行路线", description = "根据id删除接口")
  @ApiResponse(responseCode = "200", description = "OK")
  @DeleteMapping(value = "/delRoute", produces = MediaType.APPLICATION_JSON_VALUE)
  public Boolean delRoute(@RequestBody @Validated BaseManyLongIdDTO inputDTO) {
    return routeService.delRoute(inputDTO);
  }
  
  @Operation(summary = "编辑骑行路线", description = "编辑骑行路线接口")
  @ApiResponse(responseCode = "200", description = "OK")
  @PatchMapping(value = "/editRoute", produces = MediaType.APPLICATION_JSON_VALUE)
  public Boolean addRoute(@RequestBody @Validated EditRouteDTO inputDTO) {
    return routeService.editRoute(inputDTO);
  }
}